﻿<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="ImeiList.aspx.cs" Inherits="GPSTrackingClientsWebsiteManager.Espanol.Pages.ImeiList" %>

<!DOCTYPE html>

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
    <style type="text/css">
        .auto-style1 {
            width: 100%;
            height:230px;
        }
    </style>
    <script src="../../Javascript/jquery-1.8.0.min.js"></script>
    <script src="../../Javascript/messi.js"></script>
    <script src="../../Javascript/WindowMessagePlugin.js"></script>
    <link href="../../Css/messi.css" rel="stylesheet" />

    <link href="../../Css/GPSTrakingClientsWebsiteManager.css" rel="stylesheet" />

</head>
<body>
    <form id="form1" runat="server">
        <telerik:RadCodeBlock ID="RadCodeBlock1" runat="server">
            <script type="text/javascript">
                function ImeiGrid_OnRowClick(sender, eventArgs) {
                    var grid = sender;
                    var MasterTable = grid.get_masterTableView();
                    var row = MasterTable.get_dataItems()[eventArgs.get_itemIndexHierarchical()];
                    //Get Values
                    var imeiColumn = MasterTable.getCellByColumnUniqueName(row, "Imei");
                    var nameColumn = MasterTable.getCellByColumnUniqueName(row, "Name");
                    var simNumberColumn = MasterTable.getCellByColumnUniqueName(row, "SimNumber");
                    var descriptionColumn = MasterTable.getCellByColumnUniqueName(row, "Description");
                    var imeiTypeIdColumn = MasterTable.getCellByColumnUniqueName(row, "ImeiTypeId");
                    var gpsModelIdColumn = MasterTable.getCellByColumnUniqueName(row, "GpsModelId");
                    var gpsModelNameColumn = MasterTable.getCellByColumnUniqueName(row, "GpsModelIdSource.Name");

                    //Set Values
                    document.getElementById('<%= lblImei.ClientID %>').innerHTML = imeiColumn.innerHTML;
                    document.getElementById('<%= txtName.ClientID %>').value = nameColumn.innerHTML;
                    document.getElementById('<%= txtSimNumber.ClientID %>').value = simNumberColumn.innerHTML;
                    $find('<%= txtDescription.ClientID %>').set_value(descriptionColumn.innerHTML);
                    $find('<%= cmbImeiType.ClientID%>').findItemByValue(imeiTypeIdColumn.innerHTML).select();
                    document.getElementById('<%= lblGPSModel.ClientID %>').innerHTML = gpsModelNameColumn.textContent;
                    document.getElementById('<%= HiddenField1.ClientID %>').value = gpsModelIdColumn.textContent;
                    document.getElementById('<%= HiddenField2.ClientID %>').value = imeiColumn.innerHTML;


                    $find('<%= btnSave.ClientID%>').set_enabled(true);
                }

            </script>

        </telerik:RadCodeBlock>


        <div>

            <h2>Lista de GPS registrados</h2>

            <table class="auto-style1">
                <tr>
                    <td style="vertical-align: top">
                        <fieldset>
                            <legend>Lista de GPS</legend>
                            <telerik:RadGrid ID="ImeiGrid" Height="230px" runat="server" AutoGenerateColumns="False" CellSpacing="0" GridLines="None" OnNeedDataSource="ImeiGrid_NeedDataSource" Skin="Metro">
                                <ClientSettings>
                                    <Selecting AllowRowSelect="True" />
                                    <ClientEvents OnRowClick="ImeiGrid_OnRowClick" />
                                </ClientSettings>
                                <MasterTableView>
                                    <CommandItemSettings ExportToPdfText="Export to PDF"></CommandItemSettings>

                                    <RowIndicatorColumn Visible="True" FilterControlAltText="Filter RowIndicator column">
                                        <HeaderStyle Width="20px"></HeaderStyle>
                                    </RowIndicatorColumn>

                                    <ExpandCollapseColumn Visible="True" FilterControlAltText="Filter ExpandColumn column">
                                        <HeaderStyle Width="20px"></HeaderStyle>
                                    </ExpandCollapseColumn>

                                    <Columns>              
                                        <telerik:GridBoundColumn DataField="Imei" FilterControlAltText="Filter Name column" HeaderText="Imei" UniqueName="Imei">
                                        </telerik:GridBoundColumn>
                                        <telerik:GridBoundColumn DataField="Name" FilterControlAltText="Filter Name column" HeaderText="Nombre" UniqueName="Name">
                                        </telerik:GridBoundColumn>
                                        <telerik:GridMaskedColumn DataField="SimNumber" DisplayMask="" FilterControlAltText="Filter SimNumber column" HeaderText="Número SIM" Mask="" UniqueName="SimNumber">
                                        </telerik:GridMaskedColumn>
                                        <telerik:GridBoundColumn DataField="Description" FilterControlAltText="Filter Description column" HeaderText="Descripción" UniqueName="Description">
                                        </telerik:GridBoundColumn>
                                        <telerik:GridBoundColumn DataField="ImeiTypeId" FilterControlAltText="Filter Description column" HeaderText="ImeiTypeId" UniqueName="ImeiTypeId">
                                        </telerik:GridBoundColumn>
                                        <telerik:GridBoundColumn DataField="GpsModelId" FilterControlAltText="Filter Description column" HeaderText="GpsModelId" UniqueName="GpsModelId">
                                        </telerik:GridBoundColumn>
                                        <telerik:GridBoundColumn DataField="GpsModelIdSource.Name" FilterControlAltText="Filter Description column" HeaderText="Modelo" UniqueName="GpsModelIdSource.Name">
                                        </telerik:GridBoundColumn>
                                    </Columns>

                                    <EditFormSettings>
                                        <EditColumn FilterControlAltText="Filter EditCommandColumn column"></EditColumn>
                                    </EditFormSettings>
                                </MasterTableView>

                                <FilterMenu EnableImageSprites="False"></FilterMenu>
                            </telerik:RadGrid>
                        </fieldset>
                    </td>
                    <td style="vertical-align: top">
                        <fieldset>
                            <legend>Información del GPS</legend>
                            <table class="auto-style1">
                                <tr>
                                    <td>Imei:</td>
                                    <td>
                                        <asp:Label ID="lblImei" runat="server" Text="..."></asp:Label>
                                        <asp:HiddenField ID="HiddenField2" runat="server" />
                                    </td>
                                </tr>
                                <tr>
                                    <td>Nombre:</td>
                                    <td>
                                        <asp:TextBox ID="txtName" runat="server" MaxLength="15">
                                        </asp:TextBox>
                                    </td>
                                </tr>
                                <tr>
                                    <td>Número SIM:</td>
                                    <td>
                                        <asp:TextBox ID="txtSimNumber" runat="server" MaxLength="8">
                                        </asp:TextBox>
                                    </td>
                                </tr>
                                <tr>
                                    <td>Descripción:</td>
                                    <td>
                                        <telerik:RadTextBox ID="txtDescription" runat="server" Height="62px" TextMode="MultiLine">
                                        </telerik:RadTextBox>
                                    </td>
                                </tr>
                                <tr>
                                    <td>Tipo:</td>
                                    <td>
                                        <telerik:RadComboBox ID="cmbImeiType" runat="server" DataTextField="Description" DataValueField="ImeiTypeId">
                                        </telerik:RadComboBox>
                                    </td>
                                </tr>
                                <tr>
                                    <td>Modelo GPS:</td>
                                    <td>
                                        <asp:Label ID="lblGPSModel" runat="server" Text="..."></asp:Label>
                                        <asp:HiddenField ID="HiddenField1" runat="server" />
                                    </td>
                                </tr>
                                <tr>
                                    <td>&nbsp;</td>
                                    <td>
                                        <telerik:RadButton ID="btnSave" runat="server" Text="Guardar" OnClick="btnSave_Click" CausesValidation="true" Enabled="false">
                                        </telerik:RadButton>
                                    </td>
                                </tr>
                            </table>
                        </fieldset>
                    </td>
                </tr>
            </table>


        </div>
        <telerik:RadScriptManager ID="RadScriptManager1" runat="server"></telerik:RadScriptManager>
        <telerik:RadWindow ID="RadWindow1" runat="server"></telerik:RadWindow>
        <telerik:RadInputManager ID="RadInputManager1" runat="server">
            <telerik:TextBoxSetting>
                <TargetControls>
                    <telerik:TargetInput ControlID="txtName" />
                    <telerik:TargetInput ControlID="txtSimNumber" />
                </TargetControls>
                <Validation IsRequired="True" />
            </telerik:TextBoxSetting>
        </telerik:RadInputManager>
        <telerik:RadAjaxManager ID="RadAjaxManager1" runat="server">
            <AjaxSettings>
                <telerik:AjaxSetting AjaxControlID="ImeiGrid">
                    <UpdatedControls>
                        <telerik:AjaxUpdatedControl ControlID="txtName" />
                        <telerik:AjaxUpdatedControl ControlID="txtSimNumber" />
                        <telerik:AjaxUpdatedControl ControlID="txtDescription" />
                        <telerik:AjaxUpdatedControl ControlID="cmbImeiType" />
                        <telerik:AjaxUpdatedControl ControlID="lblGPSModel" />
                    </UpdatedControls>
                </telerik:AjaxSetting>
                <telerik:AjaxSetting AjaxControlID="btnSave">
                    <UpdatedControls>
                        <telerik:AjaxUpdatedControl ControlID="lblImei" />
                        <telerik:AjaxUpdatedControl ControlID="btnSave" />
                        <telerik:AjaxUpdatedControl ControlID="RadNotification1" />
                    </UpdatedControls>
                </telerik:AjaxSetting>
            </AjaxSettings>
        </telerik:RadAjaxManager>
        <telerik:RadNotification ID="RadNotification1" runat="server" Position="TopRight" Skin="Metro" Text="Guardado" VisibleTitlebar="False">
        </telerik:RadNotification>
    </form>

</body>
</html>
